package com.ad.pet.app.login.adapter;

import android.support.annotation.Nullable;
import android.widget.TextView;

import com.ad.pet.R;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

/**
 * Created by SEELE on 2018/3/21.
 */

public class CharAdapter extends BaseQuickAdapter<Character,BaseViewHolder> {
    private boolean[] flag;
    public CharAdapter( @Nullable List<Character> data) {
        super(R.layout.item_char_select, data);
        flag = new boolean[data.size()];
        for (int i = 0; i < data.size(); i++) {
            flag[i]=false;
        }
    }

    @Override
    protected void convert(BaseViewHolder helper, Character item) {
        TextView textView = helper.getView(R.id.tv_char);
//        RelativeLayout relativeLayout = helper.getView(R.id.relayout_bg);
        textView.setText(item.toString());
//        if (flag[helper.getLayoutPosition()]){
//            relativeLayout.setBackgroundResource(R.drawable.shap_red_char_bg);
//            textView.setTextColor(mContext.getResources().getColor(R.color.white));
//        }else {
//            relativeLayout.setBackgroundResource(R.drawable.shap_white_char_bg);
//            textView.setTextColor(mContext.getResources().getColor(R.color.graycf));
//        }

    }

    public void setClickLabel(int position) {
        for (int i = 0; i < flag.length; i++) {
            if (i==position){
                flag[i]=true;
            }else {
                flag[i]=false;
            }
        }
        notifyDataSetChanged();
    }
}
